# -*- coding: utf-8 -*-

from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base

from InitDB import check_and_drop_database


# 数据库连接配置
DATABASE_URL = "mysql+mysqlconnector://root:Mariadb119@localhost:3306/testDB"

# 初始化数据库
check_and_drop_database()
# 创建引擎
engine = create_engine(DATABASE_URL, echo=False)

# 创建会话类
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)

# 声明一个Base，用于继承生成ORM模型
Base = declarative_base()
